package main

import (
	"flag"
	"fmt"
	api "iotall/iottest/entity"
	"iotall/iottest/hmyg"
	"runtime"

	"time"
)

func main() {

	i := 0
	c := 0
	s := 0
	var ServerAddr = ""

	flag.StringVar(&ServerAddr, "h", "127.0.0.1:7009", "ServerAddr")

	flag.IntVar(&i, "i", 1, "起始编号")
	flag.IntVar(&c, "c", 1, "个数")
	flag.IntVar(&s, "s", 10, "心跳间隔")

	flag.Parse()

	fmt.Printf("开始id：%v 个数：%v 心跳间隔：%v\r\n", i, c, s)
	api.GloabSetting.ServerAddr = "http://127.0.0.1:7009" // ServerAddr
	api.GloabSetting.StartId = byte(i)
	api.GloabSetting.IdCount = c
	api.GloabSetting.HeathDuration = s

	//tcp28175.Start()
	hmyg.Start()

	go func() {
		for {
			fmt.Printf("\r%v---连接数：%v    心跳 上传:%v 确认:%v  指令 下发:%v 确认%v 协程%v",
				time.Now(),
				*api.RunSum.ConnOk,

				*api.RunSum.XtUp,
				*api.RunSum.XtBack,

				*api.RunSum.ServerCmd,
				*api.RunSum.ServerCmdConfirm,

				runtime.NumGoroutine(),
			)
			time.Sleep(time.Second * 1)
		}
	}()
	select {}
}
